<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Grom Hellscream
 * Date: 11/2/12
 * Time: 7:48 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();

$donvis = $this->get('donvi');
$donvi = $donvis[0];
$khoi = $this->get('khoi');
$phongtructhuocs = $this->get('phongtructhuocs');
$canbotructhuocs = $this->get('canbotructhuocs');
$lanhdaos = $this->get('lanhDaos');
$canboinfos = $this->get('thongTinNhanSu');
$hosocanbo = VastHelper::getHosocanbo();
$donvilanhdao = VastHelper::getDonViLanhDao(); 
?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=donvitructhuoc&id=' . $khoi->id); ?>"><?php echo $khoi->ten ?></a> »
        <span><?php echo $donvi->ten; ?></span>        
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">
        <?php echo $donvi->ten; ?>
        <?php if (JFactory::getUser()->authorise('vast.donvi.edit', 'com_vast') || (JFactory::getUser()->authorise('vast.donvi.edit.own', 'com_vast') && $donvilanhdao !== NULL && $donvilanhdao->donviid == $donvi->id)): ?>
        <a href="index.php?option=com_vast&view=donvi&layout=edit&id=<?php echo $donvi->id; ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Cập nhật</a>
        <?php endif; ?>
    </h3>
    <div class="single">
        <?php if (file_exists($donvi->hinhanh)) { ?>
            <img width="300" height="225" src="<?php echo $donvi->hinhanh; ?>" alt="<?php echo $donvi->ten; ?>" class="alignright size-medium wp-image-83"/>
        <?php } else { ?>
            <img width="300" height="225" src="<?php echo $this->baseurl . '/media/com_vast/images/default_image.jpg'; ?>" class="alignright size-medium wp-image-83"/>
        <?php } ?>
    
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Địa chỉ:
            </strong>
            <?php echo $donvi->diachi; ?>
        </p>
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Fax:
            </strong>
            <?php echo $donvi->fax; ?>
        </p>
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Số điện thoại:
            </strong>
            <?php echo $donvi->sodienthoai; ?>
        </p>
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Website:
            </strong>
            <?php echo $donvi->website; ?>
        </p>
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Chức năng chính:
            </strong>
            <?php echo $donvi->chucnang; ?>
        </p>
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Nhiệm vụ:
            </strong>
            <?php echo $donvi->nhiemvu; ?>
        </p>
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Hoạt động thường xuyên:
            </strong>
            <?php echo $donvi->hoatdongthuongxuyen; ?>
        </p>
        <p style="text-align:justify;text-justify:inter-word;">
            <strong style="text-indent: 20px;">
                + Các thông tin khác:
            </strong>
            <?php echo $donvi->thongtinkhac; ?>
        </p>
    </div>
    
    <div id="homeColumns">
    
        <div class="widget wpzoomWidget column">
            <h3 class="title blue">
                <a href="index.php?option=com_vast&view=phongtructhuocs&id=<?php echo $donvi->id; ?>">
                    Cơ cấu phòng ban
                </a>
                <?php echo " (" . count($phongtructhuocs) . ")"; ?>
            </h3>
            <ul class="posts">
                <li>
                    <?php
                    if (count($phongtructhuocs) > 0) {
                        echo '<a href="index.php?option=com_vast&view=phongtructhuocs&id=' . $donvi->id . '">+ Xem danh sách phòng ban (chi tiết)</a>';
                    }
                    ?>                                
                </li>
                    <?php
                        if (count($phongtructhuocs) <= 0)
                            echo '<li>Chưa có phòng.<div class="cleaner">&nbsp;</div></li>';
                        else foreach ($phongtructhuocs as $phong) {
                            echo '<li>';
                            echo '<div class="cover">';
                            echo '<a title=""><img height="60" width="80" alt="' . $phong->ten . '" src="' . $phong->hinhanh . '"/></a>';
                            echo '</div>';
                            echo '<h2>';
                            echo "<a href='index.php?option=com_vast&amp;view=chitietphong&amp;id=" . $phong->id . "'>" . $phong->ten . "</a>";
                            echo '</h2>';
                            echo '<p class="postmetadata">' . date("d/m/Y G:i:s e") . '</p>';
                            if (isset($phong->tomtat) && $phong->tomtat != '') {
                                echo '<p>';
                                echo $phong->tomtat;
                                echo '</p>';                            
                            }
                            echo '<div class="cleaner">&nbsp;</div>';
                            echo '</li>';
                        }
                    ?>
            </ul>
            <div class="cleaner">&nbsp;</div>
        </div>
    
        <div class="widget wpzoomWidget column column-last">
            <h3 class="title brown">
                Thông tin nhân sự
            </h3>
            <ul class="posts">
                <li>
                    <?php
                    if (count($canbotructhuocs) > 0) {
                        echo '<a href="index.php?option=com_vast&view=canbotheodonvi&id=' . $donvi->id . '">+ Xem danh sách cán bộ (chi tiết)</a>';
                    }
                    ?>                                
                </li>
                <li>    
                    <?php if (count($lanhdaos) <= 0): ?>
                    <p style="text-align:justify;text-justify:inter-word;">
                        Chưa có lãnh đạo đơn vị.                
                    </p>
                    <div class="cleaner">&nbsp;</div>
                    <?php else: ?>
                    <?php foreach ($lanhdaos as $lanhdao): ?>
                        + Lãnh đạo đơn vị: <br />
                        <li>
                            <div class="cover">
                                <a title="<?php echo $lanhdao->hoten ?>"><img height="60" width="80" alt='<?php echo $lanhdao->hoten; ?>' src='<?php if (isset($lanhdao->anhdaidien) && $lanhdao->anhdaidien != '') echo $this->baseurl . '/' . $lanhdao->anhdaidien; else echo $this->baseurl . '/media/com_vast/images/default_image.jpg'; ?>'/></a>
                            </div>
                            <h2>
                                <a href='<?php echo "index.php?option=com_vast&amp;view=chitietcanbo&amp;id=" . $lanhdao->id; ?>'><?php echo $lanhdao->hoten; ?></a>
                            </h2>
                            <p>
                                <?php 
                                    echo '+ Chức danh: ' . $lanhdao->chucdanh . '<br/>';
                                    echo '+ Số điện thoại: ' . $lanhdao->dienthoai . '<br/>';
                                    echo '+ Di động: ' . $lanhdao->didong . '<br/>'; 
                                ?>
                            </p>
                        </li>
                        <?php foreach ($canboinfos as $key=>$value): ?>
                        +&nbsp;<?php echo $key . $value; ?><br />
                        <?php endforeach; ?>
                        <li>
                        </li>
                    <?php endforeach; ?>                   
                    <?php endif; ?>
                </li>
            </ul>
            <div class="cleaner">&nbsp;</div>
        </div>
    
    </div>
    
    <div style="float: left; width: 680px;">
        <?php
        $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
        echo '<a title="Quay lại" href="' . $url . '"><span style="left: 600px; position: relative;">&laquo; Quay lại</span></a>';
        ?>    
    </div>
</div>
